//
// Created by 17775 on 2024/9/18.
//

#ifndef RAYCI_LIVEMODE_POWERPROFILES_H
#define RAYCI_LIVEMODE_POWERPROFILES_H

#include <QObject>
#include <thread>
#include "RayCiPro_C.h"
#include <QDebug>

class LiveMode_PowerProfiles: public QObject {
Q_OBJECT

signals:
    void setFractionValue(bool a, double value);
    void refreshCenter(double x_pos, double y_pos);

public:
    explicit LiveMode_PowerProfiles(int &docId) : _nDocIdLive(docId) {

    }

    ~LiveMode_PowerProfiles() override;

    int _iIdAOI = 0;
    int _iMethod = 0;
    double _positionX_px = 0;
    double _positionY_px = 0;
    double x_pos = 0;
    double y_pos = 0;
    std::thread m_cursorPowerFractionThread;
    std::atomic<bool> _isGettingNewCursorPowerFraction = false;
    std::atomic<bool> _bIsGettingPowerPosition = false;

    double getCursorPosition();
    QString getUnitSpatial() const;
    double getViewCenterXPosition_px();
    double getViewCenterYPosition_px();
    void setCursorPosition(double pos) const;
    void setCursorPowerFraction(double dFraction) const;
    void getFraction();
    void getCursorPowerFraction();
    void stopCursorPowerFractionThread();
    void setPosition_px(QString unit, double sizeX, double sizeY, double dPosX, double dPosY);
    double unitConversion(const QString& unit, double size);
    void setAxisRatio(double dRatioX, double dRatioY) const;
    void getAdjustmentAOI();
    void getAdjustmentMethod();
    void setAdjustmentActive(bool bActive) const;
    void setAdjustmentAOI(int iIdAOI) const;
    void setAdjustmentMethod(int iMethod) const;
    void closePowerProfileWindow() const;

private:
    int _nDocIdLive = 0;
    double dCurPos = 0;
    double _dFraction = 0;
};


#endif //RAYCI_LIVEMODE_POWERPROFILES_H
